
<? include("/inc/header.html") {} ?>

<div class="col-lg-5">
	<div class="panel" overflow:auto;">
		<div class="panel-body pan " style="width:auto; overflow: auto;">
			<div class="form-body pal"
				style="float:left;width:100%; overflow: auto;">
				<div>
					<label for="inputUsername" class="col-md-3 control-label">
						<div align="right">中文名称 <span
						class='require'>*</span> 
						</div> </label>
					<div class="col-md-7">
						<div class="input-icon">
							<input id="nameZh" type="text" class="form-control" />
						</div>
					</div>
				</div>
				<div>
					<label for="inputUsername" class="col-md-3 control-label">
						<div align="right">英文名称 <span
						class='require'>*</span> 
						</div> </label>
					<div class="col-md-7">
						<div class="input-icon">
							<input id="nameEn" type="text" class="form-control" />
						</div>
					</div>
				</div>

				<div>
					<label for="inputUsername" class="col-md-3 control-label">
						<div align="right">分类号<span
						class='require'>*</span> 
						</div> </label>
					<div class="col-md-7">
						<div class="input-icon">
							<input id="sid" type="text" class="form-control" />
						</div>
					</div>
				</div>
				<div>
					<label for="inputUsername" class="col-md-3 control-label">
						<div align="right">分类图标 
						</div> </label>
					<div class="col-md-7">
						<div class="input-icon">
							<input id="icon" type="text" class="form-control" />
						</div>
					</div>
				</div>

				<div>
					<label for="inputUsername" class="col-md-3 control-label">
						<div align="right">排序<span
						class='require'>*</span> 
						</div> </label>
					<div class="col-md-7">
						<div class="input-icon">
							<input id="sort" type="text" class="form-control" />
						</div>
					</div>
				</div>
				<div>
					<label for="inputUsername" class="col-md-3 control-label">父节点<span
						class='require'>*</span> </label>
					<div class="col-md-9">
						<div class="input-group input-group-sm mbs">
							<input id="parentclassname" type="text" value="根目录"
								class="form-control" disabled="true" /> <span
								class="input-group-btn">
								<button onclick="menuZTree()" type="button"
									data-toggle="dropdown" class="btn btn-success dropdown-toggle">选择...</button>
							</span> <input id="parentClassid" type="hidden" value="0"
								class="form-control" />
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	var menuid = window.parent.getzTreeid();
	var menuname = window.parent.getztreename();
	if (menuname != null) {
		$("#parentclassname").val(menuname);
		$("#parentClassid").val(menuid);
	}
	//选择父类
	function menuZTree() {
		parent.layer.open({
			type : 2,
			area : [ '560px', '600px' ],
			fix : false, //不固定
			scrollbar : false,
			shadeClose : true,
			//move : false,
			title : "选择父节点",
			skin : 'layui-layer-rim', //加上边框
			btn : [ '保存 ', '关闭' ],
			content : [
					"baikeCategory_menu_zree.html?winName="
							+ window.name, 'no' ],
			yes : function(index, layer) {
				var iframeWin = parent.window[layer.find('iframe')[0]['name']];
				iframeWin.save();
			},
			cancel : function(index) {
			}
		});
	}
	function save() {
		 if($.trim($("#nameZh").val()).length<1) {
    	        	alert('中文名称不能为空！');
    	        	return null;
    	    }
		 if($.trim($("#nameEn").val()).length<1) {
    	        	alert('英文名称不能为空！');
    	        	return null;
    	    }
		 if($.trim($("#sid").val()).length<1) {
    	        	alert('分类号不能为空！');
    	        	return null;
    	    }
		 if($.trim($("#sort").val()).length<1) {
    	        	alert('排序不能为空！');
    	        	return null;
    	    }
		 if($.trim($("#parentClassid").val()).length<1) {
    	        	alert('父节点不能为空！');
    	        	return null;
    	    }
		$.ajax({
			type : "post",
			url : "baikeCategoryAddMent.do",
			dataType : "json",
			data : {
				"nameZh" : $("#nameZh").val(),
				"nameEn" : $("#nameEn").val(),
				"sid" : $("#sid").val(),
				"sort" : $("#sort").val(),
				"pid" : $("#parentClassid").val(),
				"icon" : $("#icon").val(),
			},
			beforeSend : function(XMLHttpRequest) {
			},
			success : function padlock() {
				var index = parent.layer.getFrameIndex(window.name);
				window.parent.initTree();
				parent.layer.msg('添加成功！');
				parent.layer.close(index);
			}
		});
	}
	
</script>

